package com.alicom.dysms.api;

import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;


public class SmsDemo {

    public void testOne(String yanzem, String userPhone) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI4GELqXRYTFrM6yqtecGd", "R4h7GnLb6U0Xod0rXEdHesoTgZj7gJ");
        IAcsClient client = new DefaultAcsClient(profile);
        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.POST);
        request.setSysDomain("dysmsapi.aliyuncs.com");
        request.setSysVersion("2017-05-25");
        request.setSysAction("SendSms");
        request.putQueryParameter("RegionId", "cn-hangzhou");
        request.putQueryParameter("PhoneNumbers", userPhone);
        request.putQueryParameter("SignName", "物业邦");
        request.putQueryParameter("TemplateCode", "SMS_192572757");
        JSONObject json = new JSONObject();
        System.out.println(yanzem);
        json.put("code", yanzem);
        request.putQueryParameter("TemplateParam", json.toJSONString());

        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ClientException var9) {
            var9.printStackTrace();
        }

    }
}
